#include"progressBar.h"
#define Style '='

const char* lable = "-/|\\";

#ifdef v1
void progBar()
{
   char bar[100] = {0};
   int cnt = 0;
   while(cnt <= 100)
   {
      printf("[%-100s][%d%%][%c]\r", bar,cnt,lable[cnt%4]);
      fflush(stdout);
      bar[cnt++] = Style;
      usleep(100000);
   }
   printf("\n");
}
#else
void progBar(double total, double current)
{
   char bar[100] = {0};
   //比率：
   double rate = current*100/total;
   //计数器：
   int cnt = 0;
   //网络回环总次数：
   int loop_count = (int)rate;
   while(cnt <= loop_count)
   {
      bar[cnt++] = Style;
   }
   
   printf("[%-100s][%4.1lf%%][%c]\r", bar,rate,lable[cnt%4]);
   fflush(stdout);
} 
#endif
